package com.pengbei.enshrine.common.utils;

import android.Manifest;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import android.view.View;

import com.pengbei.enshrine.common.dialog.callback.BounceInterpolator;

import java.io.File;

public class CommonUtils {

    public final static int CONNECT_TIMEOUT = 180;
    public final static int READ_TIMEOUT = 180;
    public final static int WRITE_TIMEOUT = 180;
    public static String time = "60";//短信倒计时秒

    public final static String permission_install = Manifest.permission.REQUEST_INSTALL_PACKAGES;
    public final static String permission_image = Manifest.permission.READ_MEDIA_IMAGES;
    public final static String permission_video = Manifest.permission.READ_MEDIA_VIDEO;
    public final static String permission_audio = Manifest.permission.READ_MEDIA_AUDIO;
    public final static String permission_camera = Manifest.permission.CAMERA;

    public static void starAnimation(View view){
        ObjectAnimator animatorX = ObjectAnimator.ofFloat(view,"scaleX",0.5f,1.0f);
        ObjectAnimator animatorY = ObjectAnimator.ofFloat(view,"scaleY",0.5f,1.0f);
        AnimatorSet set = new AnimatorSet();
        set.setDuration(500);
        set.setInterpolator(new BounceInterpolator(0.4f));
        set.playTogether(animatorX,animatorY);
        set.start();
    }

    public static void Logs(String tag, String msg) {  //信息太长,分段打印
        //因为String的length是字符数量不是字节数量所以为了防止中文字符过多，
        //  把4*1024的MAX字节打印长度改为2001字符数
        int max_str_length = 2001 - tag.length();
        //大于4000时
        while (msg.length() > max_str_length) {
            Log.i(tag, msg.substring(0, max_str_length));
            msg = msg.substring(max_str_length);
        }
        //剩余部分
        Log.i(tag, msg);
    }


}
